package com.eshop.modules.activity.rest;

import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.validation.annotation.Validated;
import com.eshop.modules.activity.domain.UserExtract;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import io.swagger.annotations.ApiOperation;
import com.eshop.logging.aop.log.Log;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.data.domain.Pageable;
import com.eshop.modules.activity.service.dto.UserExtractQueryCriteria;
import com.eshop.modules.activity.service.UserExtractService;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import io.swagger.annotations.Api;

@Api(tags = { "商城:提现管理" })
@RestController
@RequestMapping({ "api" })
public class UserExtractController
{
    private final UserExtractService userExtractService;
    
    public UserExtractController(final UserExtractService userExtractService) {
        this.userExtractService = userExtractService;
    }
    
    @Log("查询")
    @ApiOperation("查询")
    @GetMapping({ "/yxUserExtract" })
    @PreAuthorize("hasAnyRole('admin','YXUSEREXTRACT_ALL','YXUSEREXTRACT_SELECT')")
    public ResponseEntity getYxUserExtracts(final UserExtractQueryCriteria criteria, final Pageable pageable) {
        return new ResponseEntity(this.userExtractService.queryAll(criteria, pageable), HttpStatus.OK);
    }
    
    @Log("修改审核")
    @ApiOperation("修改审核")
    @PutMapping({ "/yxUserExtract" })
    @PreAuthorize("hasAnyRole('admin','YXUSEREXTRACT_ALL','YXUSEREXTRACT_EDIT')")
    public ResponseEntity update(@Validated @RequestBody final UserExtract resources) {
        this.userExtractService.doExtract(resources);
        return new ResponseEntity(HttpStatus.NO_CONTENT);
    }
}
